//
//  JTableHelper.m
//  AFNetworking
//
//  Created by 计海峰 on 2020/8/16.
//

#import "JTableHelper.h"
#import <CooperSDK/CooperSDK.h>

@implementation JTableHelper

/// 跳转到vc
/// @param vc vc
void routerTo(UIViewController *vc) {
    UIViewController *currentVC = [JUtil topVC];
    if (vc && currentVC && currentVC.navigationController) {
        [currentVC.navigationController pushViewController:vc animated:true];
    }
}

/// push 返回上一级
void navBack(void) {
    UIViewController *currentVC = [JUtil topVC];
    if (currentVC && currentVC.navigationController) {
        [currentVC.navigationController popViewControllerAnimated:true];
    }
}

/// push 返回上级
/// @param num 数量
void navBackTo(int num) {
    UIViewController *currentVC = [JUtil topVC];
    if (currentVC && currentVC.navigationController) {
        [JUtil popNumController:num orToNumController:-1 andVC:currentVC];
    }
}


/// 顶部vc
+ (UIViewController *)topVC {
    UIWindow * window = [[UIApplication sharedApplication] keyWindow];
    UIViewController *vc = [window currentTopViewController];
    if(jBaseSDK.debugModel) {
        NSLog(@"顶部vc: %@", vc);
    }
    return vc;
}

@end
